﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Logic
{
    public class LogicBase
    {

        private static Dictionary<string, Utilities.Observer.Listen> EventSubscribeList = new Dictionary<string, Utilities.Observer.Listen>();
        protected HttpContextBase context;
        public LogicBase()
        {
            //init;
            LogicBase.Add("MemberRegister", new LogicListen());
        }

        public static void Add(string eventName, Utilities.Observer.Listen eventNodify)
        {
            if (!EventSubscribeList.ContainsKey(eventName))
            {
                EventSubscribeList.Add(eventName, eventNodify);
            }
        }

        public static Utilities.Observer.Listen EventNotify(string eventName)
        {
            return EventSubscribeList[eventName];
        }
    }

    public class EventList
    {
        public string EventName;
        public LogicListen Subscribe;
    }

    public class LogicListen : Utilities.Observer.Listen
    {
        public LogicListen()
        {
            this.Register("Register", new Test());
            this.Register("A", new Test1());
        }
    }

    public class Test : Utilities.Observer.IProcess
    {
        public void OnNext(System.Web.HttpContextBase context, IList<object> param)
        {
            context.Response.Write("Subscribe 1;");
        }
    }

    public class Test1 : Utilities.Observer.IProcess
    {
        public void OnNext(System.Web.HttpContextBase context, IList<object> param)
        {
            context.Response.Write("Subscribe 2;");
        }
    }
}
